package com.example.home.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.home.activity.R;
import com.example.home.viewmodel.GoodsList.BrotherCategory;

import java.util.List;

public class GoodsNavigationAdapter extends RecyclerView.Adapter<GoodsNavigationAdapter.ViewHolder> {
    private Context ctx;

    private List<BrotherCategory> brotherCategories;

    public GoodsNavigationAdapter(Context ctx, List<BrotherCategory> brotherCategories) {
        this.ctx = ctx;
        this.brotherCategories = brotherCategories;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(this.ctx).inflate(R.layout.goodslist_navigation,parent,false);
        ViewHolder viewHolder = new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.goodslist_navigation_text.setText(this.brotherCategories.get(position).getName());
    }

    @Override
    public int getItemCount() {
        return this.brotherCategories.size();
    }
    class ViewHolder extends RecyclerView.ViewHolder {
        TextView goodslist_navigation_text;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            this.goodslist_navigation_text = itemView.findViewById(R.id.goodslist_navigation_text);
        }
    }
}
